import http from '@/utils/http'
import type { LabelValueState } from '@/types/global'
const BASE_URL = '/task/testInfo'

export interface TestInfoResp {
  id: string
  name: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface TestInfoDetailResp {
  id: string
  name: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface TestInfoQuery {
  name: string
  createUser: string
  createTime: string
  sort: Array<string>
}
export interface TestInfoPageQuery extends TestInfoQuery, PageQuery {}

/** @desc 查询试验任务名称列表 */
export function listTestInfo(query: TestInfoPageQuery) {
  return http.get<PageRes<TestInfoResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询试验任务名称详情 */
export function getTestInfo(id: string) {
  return http.get<TestInfoDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增试验任务名称 */
export function addTestInfo(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改试验任务名称 */
export function updateTestInfo(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除试验任务名称 */
export function deleteTestInfo(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出试验任务名称 */
export function exportTestInfo(query: TestInfoQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}

/** @desc 查询试验任务名称列表 */
export function listTestDict(query?: { status: number }) {
  return http.get<LabelValueState[]>(`${BASE_URL}/dict`, query)
}